Hi,
It's a code for copying a file. It had been working fine but now something goes wrong and it causes the main process to crash, even without an error message.
I can't figure out what's wrong here, so I am adding the code here.
Here is where it crashes, ntdll.dll. From OllyDbg.Code:#include <windows.h> #include <stdio.h> #include <commctrl.h> #include <stdlib.h> #include <time.h> CopyAFile(char * src, char * trg){ char c = 0; FILE *fp = fopen(src, "rb"); FILE *fp1 = fopen(trg, "wb"); if(!(fp && fp1)){ MessageBox(0, "fopen()", 0, 0); return 0; } fseek(fp, 0, SEEK_SET); while(!feof(fp)){ fscanf(fp, "%c", &c); fprintf(fp1, "%c", c); //It crashes here, the first time fprintf() called } fclose(fp); fclose(fp1); return 1; }
It would be greatly appreciated if you can point out my mistake.Code:7C901E24 > FF75 10 PUSH DWORD PTR SS:[EBP+10] 7C901E27 . 57 PUSH EDI 7C901E28 . 56 PUSH ESI 7C901E29 . E8 26FDFFFF CALL ntdll.7C901B54 7C901E2E .^EB AE JMP SHORT ntdll.7C901DDE 7C901E30 > 0FB706 MOVZX EAX,WORD PTR DS:[ESI] 7C901E33 . 8B4D 10 MOV ECX,DWORD PTR SS:[EBP+10] 7C901E36 . 0301 ADD EAX,DWORD PTR DS:[ECX] 7C901E38 . 3D 00FE0000 CMP EAX,0FE00 7C901E3D .^0F87 EEEDFFFF JA ntdll.7C900C31 7C901E43 . 807D 14 00 CMP BYTE PTR SS:[EBP+14],0 7C901E47 . 0F85 977A0300 JNZ ntdll.7C9398E4 7C901E4D > 8B4E 0C MOV ECX,DWORD PTR DS:[ESI+C] 7C901E50 . 8D46 08 LEA EAX,DWORD PTR DS:[ESI+8] 7C901E53 . 8B10 MOV EDX,DWORD PTR DS:[EAX] 7C901E55 . 894D 08 MOV DWORD PTR SS:[EBP+8],ECX 7C901E58 . 8B09 MOV ECX,DWORD PTR DS:[ECX] ;; DS:[00000000]=??? ;;Access violation reading 00000000 7C901E5A . 3B4A 04 CMP ECX,DWORD PTR DS:[EDX+4] 7C901E5D . 8955 0C MOV DWORD PTR SS:[EBP+C],EDX
Thanks...


